#!usr/bin/node

const http = require('http'),
      addr = 'http://wangding:123@www.baidu.com:8080/a/b/c?age=20&gender=M#/d/e/f';


function print(url) {
  console.log(url.protocol);
  console.log(url.username);
  console.log(url.password);
  console.log(url.hostname);
  console.log(url.port);
  console.log(url.pathname);
  console.log(url.pathname.split('/'));
  console.log(url.search);
  console.log(url.hash);
  console.log(url.searchParams.get('age'));
  console.log(url.searchParams.get('gender'));
}

//print(new URL(addr));

//process.exit();
http.createServer((req,res) => {
    const urlBase = `http://${req.headers.host}`;
    print(new URL(req.url,urlBase));
    res.end("ok");
}).listen(8080);
